# Maintainer: Hoang Nguyen <folliekazetani@protonmail.com>
pkgname=mangal
pkgver=4.0.6
pkgrel=13
pkgdesc="Fancy TUI manga downloader"
url="https://github.com/metafates/mangal"
arch="all"
license="MIT"
makedepends="go"
subpackages="
	$pkgname-bash-completion
	$pkgname-fish-completion
	$pkgname-zsh-completion
	"
source="$pkgname-$pkgver.tar.gz::https://github.com/metafates/mangal/archive/refs/tags/v$pkgver.tar.gz"
options="!check" # connects to dead api

build() {
	local _goldflags="
	-X github.com/metafates/mangal/constant.BuiltAt=$(date -u "+%Y-%m-%dT%H:%M:%SZ" ${SOURCE_DATE_EPOCH:+-d @$SOURCE_DATE_EPOCH})
	-X github.com/metafates/mangal/constant.BuiltBy=AlpineLinux
	-X github.com/metafates/mangal/constant.Revision=0000000
	"
	go build -v -ldflags "$_goldflags"
}

check() {
	go test ./...
}

package() {
	install -Dm755 $pkgname -t "$pkgdir"/usr/bin/

	install -Dm644 completions/$pkgname.bash \
		"$pkgdir"/usr/share/bash-completion/completions/$pkgname
	install -Dm644 completions/$pkgname.fish \
		"$pkgdir"/usr/share/fish/vendor_completions.d/$pkgname.fish
	install -Dm644 completions/$pkgname.zsh \
		"$pkgdir"/usr/share/zsh/site-functions/_$pkgname
}

sha512sums="
b826dd77cb66efe39812eb6c00439d2578dd32456fbb038509e4a92da52e96d06c8a55d8d85fde2414dcde57197a181cf8a95c0a2bd90903f11340fceda9059b  mangal-4.0.6.tar.gz
"
